<template>
  <div class="out" @click="goBig(data)">
    <img :src="data.images[0].url" alt="" />
    <div class="title">
      <p class="title-top">{{ data.title }}</p>
      <p class="info">
        <span>
          <img :src="data.user.avatarurl" alt="" />
          {{ data.user.nickName }}
        </span>
        <span
          @click.stop="
            data.user.followed ? data.upCount-- : data.upCount++;
            data.user.followed = !data.user.followed;
          "
          :style="{ color: data.user.followed ? 'red' : 'white' }"
        >
          <i class="iconfont icon-dianzan"></i>
          {{ data.upCount }}
        </span>
      </p>
    </div>
  </div>
</template>

<script>
export default {
  props: ['data'],
  methods: {
    goBig(val) {
      this.$router.push({
        name: 'bigVideo',
        params: {
          id: val.id,
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.out {
  width: 50%;
  height: 7rem;
  float: left;
  margin-bottom: 1px;
  position: relative;
  img {
    width: 100%;
    height: 100%;
  }
  .title {
    box-sizing: border-box;
    position: absolute;
    padding: 0.2rem;
    left: 0;
    width: 100%;
    bottom: 0.1rem;
    color: white;
    .info {
      margin-top: 0.1rem;
      display: flex;
      justify-content: space-between;
      img {
        width: 0.5rem;
        height: 0.5rem;
        border-radius: 50%;
        vertical-align: middle;
      }
    }
    .title-top {
      width: 100%;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      box-sizing: border-box;
    }
  }
}
</style>
